﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace _17单向通道.Migrations
{
    /// <inheritdoc />
    public partial class AddUserLeave : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "T_User",
                columns: table => new
                {
                    ID = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_User", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "T_Leaves",
                columns: table => new
                {
                    ID = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    RequesterID = table.Column<long>(type: "bigint", nullable: false),
                    ApproverID = table.Column<long>(type: "bigint", nullable: false),
                    Remarks = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Leaves", x => x.ID);
                    table.ForeignKey(
                        name: "FK_T_Leaves_T_User_ApproverID",
                        column: x => x.ApproverID,
                        principalTable: "T_User",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_T_Leaves_T_User_RequesterID",
                        column: x => x.RequesterID,
                        principalTable: "T_User",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateIndex(
                name: "IX_T_Leaves_ApproverID",
                table: "T_Leaves",
                column: "ApproverID");

            migrationBuilder.CreateIndex(
                name: "IX_T_Leaves_RequesterID",
                table: "T_Leaves",
                column: "RequesterID");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "T_Leaves");

            migrationBuilder.DropTable(
                name: "T_User");
        }
    }
}
